<?php

function modifyBook(){
	$serverpath=$_SERVER['DOCUMENT_ROOT'];
	include ($serverpath.'/Classes/book.php');
	//serializacion
	$serial_book = file_get_contents('store_book');
	$book = unserialize($serial_book);
	//seteo de variables
	$book->set_title($_POST['title']);
	$book->set_author($_POST['author']);
	$book->set_text($_POST['textArea']);
	$book->set_section($_POST['select']);
	$book->set_price($_POST['price']);
	$book->set_amount($_POST['amount']);
	//persistencia del obj
	$book->savetofile($book->get_id());
	$serialize_client = serialize($book);
	file_put_contents('store_client',$serialize_client);
	//header('Location: profile.php');
}
function retriveBookbyId($id){
	$serverpath=$_SERVER['DOCUMENT_ROOT'];
	include ($serverpath.'/Classes/book.php');
	$filename="$serverpath.'files/books.txt";
	$fp = fopen("$filename", "r");
	while (!feof($fp)) {
		$line=fgets($fp);
		$info = explode('|', $line);
		echo '<tr>
			    	<td>'
			    	.$info[1].
					'</td>
				  </tr>';
	}
		
}
function retriveBookbyTitle($title){
	$serverpath=$_SERVER['DOCUMENT_ROOT'];
	include ($serverpath.'/Classes/book.php');
	$filename="$serverpath.'files/books.txt";
	$fp = fopen("$filename", "r");
	while (!feof($fp)) {
		$line=fgets($fp);
		$info = explode('|', $line);
		echo '<tr>
			    	<td>'
			    	.$info[1].
					'</td>
				  </tr>';
	}
		
}


?>



